local table_name = "snap_user"
local query_sql = "SELECT `name`,`level`,`skills_level`,`nickname`, `context` FROM `%s` WHERE `skills_level` > 0 ORDER BY `skills_level` DESC,`level` DESC LIMIT %d"

local M = {}

---! 数据加载
function M.load(conn, msg)
    local rows = {}
    local count = table.unpack(msg.data)
    local cmd = string.format(query_sql, table_name, count)
    local cur = conn:execute(cmd)
    local row = cur:fetch({})
    while row do
        table.insert(rows, {
            userid = row[1],
            level = math.floor(row[2] - 1000),
            rank_level = math.floor(row[3]),
            nickname = row[4],
            context = row[5],
        })
        row = cur:fetch({})
    end
    cur:close()
    return rows
end

return M
